package com.myschool.dao.impl;

import com.myschool.dao.ResultDao;
import com.myschool.pojo.Result;
import com.myschool.util.BaseDao;

import java.util.List;

public class ResultDaoImpl implements ResultDao {

    @Override
    public int add(Result result) {
        String sql = "INSERT INTO result(studentno,subjectno,examDate,STudentresult) values(?,?,?,?)";
        return BaseDao.executeUpdate(sql,result.getStudentNo(),result.getSubjectNo(),result.getExamDate(),result.getStudentResult());
    }

    @Override
    public int deleteResult(int studentno) {
        String sql = "delete from result where studentno=?;";
        return BaseDao.executeUpdate(sql,studentno);
    }

    @Override
    public int updateResult(Result result) {
        String sql = "update result set Studentresult = ? where studentno = ?;";
        return BaseDao.executeUpdate(sql,result.getStudentResult(),result.getStudentNo());
    }

    @Override
    public List showResult(Class classz) {
        String sql = "select * from"+"  "+classz.getSimpleName();
        return  BaseDao.show(sql,classz);
    }

    @Override
    public List findByStudentno(int id, Class classz) {
        String sql = "select * from"+"  "+classz.getSimpleName()+"where studentno="+id;
        return BaseDao.show(sql,classz,id);
    }
}
